package com.dd.web.base.service.impl;

import com.dd.web.base.constant.DictConstant;
import com.dd.web.base.dao.UmsDictTypeDao;
import com.dd.web.base.entity.data.UmsDictType;
import com.dd.web.base.service.UmsDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 字典类型
 */
@Service
public class UmsDictServiceImpl implements UmsDictTypeService,DictConstant {
    @Autowired
    private UmsDictTypeDao dictTypeDao;



    /**
     * 根据所有字典类型
     *
     * @return 字典类型集合信息
     */
    @Cacheable(value=REDIC_CACH_VALUE)
    @Override
    public List<UmsDictType> selectDictTypeAll()
    {
        return dictTypeDao.selectDictTypeAll();
    }





    /**
     * 新增保存字典类型信息
     *
     * @param dictType 字典类型信息
     * @return 结果
     */
    @CacheEvict(value = REDIC_CACH_VALUE)
    @Override
    public int insertDictType(UmsDictType dictType)
    {
        return dictTypeDao.insertDictType(dictType);
    }


    @Cacheable(value = REDIC_CACH_VALUE,key = "#p0")
    @Override
    public UmsDictType selectDictTypeByType(String type) {
        return this.dictTypeDao.selectDictTypeByType(type);
    }
}
